package com.easyexcel.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.easyexcel.domain.Model;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 类描述:
 *
 * @author jianweiwang
 * @version v1.0
 * @link wjw@choicesoft.com.cn
 * @date 2019/3/29 15:40
 **/
@Data
public class ExcelListener extends AnalysisEventListener {
    private List<Object> datas = new ArrayList<Object>();
    @Override
    public void invoke(Object object, AnalysisContext context) {
        Model student = new Model();
        BeanUtils.copyProperties(object,student);
        System.out.println("当前行："+context.getCurrentRowNum());
        System.out.println(student);
        datas.add(student);
        doSomething(object);
    }
    private void doSomething(Object object) {
        //1、入库调用接口
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
